package com.hqully.smartfumehood.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hqully.smartfumehood.common.vo.QueryVo;
import com.hqully.smartfumehood.entity.Unit;
import com.hqully.smartfumehood.mapper.UnitMapper;
import com.hqully.smartfumehood.service.UnitService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * <p>
 *     单位服务实现类
 * </p>
 * @author liulingyu
 * @date 2022-05-08 14:36
 * @version 1.0
 */
@Service
public class UnitServiceImpl extends ServiceImpl<UnitMapper, Unit> implements UnitService {

    @Autowired
    private UnitMapper unitMapper;

    @Override
    public PageInfo<Unit> findAllUnit(QueryVo queryVo) {
        PageHelper.startPage(queryVo.getPageNum(),queryVo.getPageSize(),true);

        List<Unit> UnitList = unitMapper.findAllUnit(queryVo.getQuery());

        PageInfo<Unit> UnitPageInfo = new PageInfo<>(UnitList);
        return UnitPageInfo;
    }

    @Override
    public Unit findUnitByName(String name) {

        return unitMapper.findUnitByName(name);
    }

    @Override
    public int addUnit(Unit unit) {
        return unitMapper.addUnit(unit);
    }

    @Override
    public int deleteUnit(Long uid) {
        return unitMapper.deleteUnit(uid);
    }

    @Override
    public int updateUnit(Unit unit) {
        return unitMapper.updateUnit(unit);
    }
}
